 import 'package:flutter_html/flutter_html.dart';
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:magic_car/util/HttpHelper.dart';
import 'package:magic_car/util/config.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:webview_flutter/webview_flutter.dart';

class AgreementPage extends StatefulWidget {
  AgreementPage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<AgreementPage> {
  var content = '';
  Map acountinfo = new Map();
  @override
  void initState() {
    super.initState();

    loaddata();
  }

  //加载数据
  loaddata() async {
    Map<String, String> map = new Map();
    SharedPreferences pref = await SharedPreferences.getInstance();

    map["type"] = pref.getString('role');

    HttpHelper.post(HttpHelper.API_Agreement, (data) async {
      print(data);
      if (data != null) {
        print(data);

        if (data["code"].toString() == "1") {
          setState(() {
            if (pref.getString('role') == '1')
              content = data['info']['inspector_agreement'];
            else
              content = data['info']['bussiness_agreement'];
            //  acountinfo = data["info"];
          });
        }
      }
    }, params: map);
  }

  Widget build(BuildContext context) {
    return new Scaffold(
        appBar: new AppBar(
          titleSpacing: 0,
          title: new Text('入驻协议',style: TextStyle(fontSize: Config.title_size),),
          backgroundColor: Colors.white,
          elevation: 0,
        ),
        body: new Container(
            child: new ListView(children: <Widget>[

          // WebView(

          //       )
          Html(
            data: content,
          ),
        ])));
  }
}
